{ ancestor of behavior types}


unit oBehavior;

interface

uses Classes, Math, oVector, uOSPRand, Generics.Collections, uOSPABA;



type
  TBehavior = class;

  TBehaviorsList = class(TList)
  private
  public
    constructor Create;
    constructor CreateCopy(paBehaviorsList: TBehaviorsList);
    destructor Destroy;override;
    function Calculate(paPedestrian: TActor): TVector;
  end;


  TBehavior = class
  private
  public
    constructor Create;
    constructor CreateCopy(paBehavior: TBehavior);
    destructor Destroy;override;
    function Calculate(paPedestrian: TActor): TVector;virtual;abstract;
  end;

implementation

constructor TBehaviorsList.Create;
begin
    inherited Create;
end;

constructor TBehaviorsList.CreateCopy(paBehaviorsList: TBehaviorsList);
begin
    inherited Create;
end;

destructor TBehaviorsList.Destroy;
begin
    inherited Destroy;
end;

function TBehaviorsList.Calculate(paPedestrian: TActor): TVector;
var ResultVector, TempVector: TVector;
    I: Integer;
begin
    ResultVector := TVector.Create;
    for I := 0 to Count - 1 do begin
        TempVector := TBehavior(Items[I]).Calculate(paPedestrian);
        ResultVector.AddSelf(TempVector);
        TempVector.Free;
    end;
    Result := ResultVector;
end;



constructor TBehavior.Create;
begin
    inherited Create;
end;

constructor TBehavior.CreateCopy(paBehavior: TBehavior);
begin
    inherited Create;
end;

destructor TBehavior.Destroy;
begin
    inherited Destroy;
end;


end.
